package zhongbo.javaweb.instagram.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import zhongbo.javaweb.instagram.dto.EmailDto;
import zhongbo.javaweb.instagram.dto.JsonRespDto;
import zhongbo.javaweb.instagram.service.EmailService;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2022年02月21日 星期一 22:10:26
 */
@Controller
@RequestMapping("Email")
@Api(value = "邮件发送相关接口", tags = {"邮件发送相关接口"})
public class EmailController {

    @Autowired
    private EmailService emailService;

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "发送一封邮件接口")
    public JsonRespDto<EmailDto> sendEmail(@RequestBody EmailDto emailDto) {
        if (emailService.sendMail(emailDto)) {
            return new JsonRespDto<EmailDto>().setData(emailDto).makeSuccess();
        }
        return new JsonRespDto<EmailDto>().makeError();
    }
}
